package 分发饼干;

import java.util.Arrays;

class Solution {
    public int findContentChildren(int[] g, int[] s) {
        int n = g.length;
        int m = s.length;
        int ret = 0;
        Arrays.sort(g);
        Arrays.sort(s);
        for (int i = 0, j = 0; i < n && j < m; i++, j++) {
            while (j < m && g[i] > s[j]) {
                j++;
            }
            if (j < m) {
                ret++;
            }
        }
        return ret;
    }
}